package com.lora.judge;

import com.lora.entity.ElectricityMeter;
import com.lora.entity.Ups;
import com.lora.entity.Wirelesssmokefeel;

import java.math.BigDecimal;

public class CheckTest {

    public static void main(String[] args) {
        CheckTest checkTest = new CheckTest();
        try {
            checkTest.test1();
            checkTest.test2();
            checkTest.test3();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void test1() throws Exception {
        Ups ups = new Ups();
        ups.setAcVoltagea(new BigDecimal("30"));
        String json = "{\"field\":\"acVoltagea\",\"epName\":\"UPS\",\"title\":\"交流旁路电压A\",\"valueType\":\"BigDecimal\",\"checks\":[{\"standard\":\"12.89\",\"algorithm\":\"GT\"},{\"standard\":\"20\",\"algorithm\":\"LT\"}]}";
        System.out.println(CheckUtil.alarm(ups, json));
    }

    // 无线烟感
    public void test2() throws Exception {
        Wirelesssmokefeel wirelesssmokefeel = new Wirelesssmokefeel();
        wirelesssmokefeel.setState("020100");
        String json = "{\"field\":\"state\"," +
                "\"customTip\":\"无线烟感[操作台上方吸顶安装]火灾报警\"," +
                "\"epName\":\"无线烟感\"," +
                "\"title\":\"设备状态\"," +
                "\"valueType\":\"String\"," +
                "\"checks\":[{\"standard\":\"020100\",\"algorithm\":\"EQ\"}]}";
        System.out.println(CheckUtil.alarm(wirelesssmokefeel, json));
        wirelesssmokefeel.setState("020300");
        json = "{\"field\":\"state\"," +
                "\"customTip\":\"无线烟感[操作台上方吸顶安装]电池低电压\"," +
                "\"epName\":\"无线烟感\"," +
                "\"title\":\"设备状态\"," +
                "\"valueType\":\"String\"," +
                "\"checks\":[{\"standard\":\"020300\",\"algorithm\":\"EQ\"}]}";
        System.out.println(CheckUtil.alarm(wirelesssmokefeel, json));
    }

    public void test3() throws Exception {
        ElectricityMeter electricityMeter = new ElectricityMeter();
        electricityMeter.setAVoltage(new BigDecimal("210"));
        String json = "{\"field\":\"aVoltage\"," +
                "\"customTip\":\"电量仪[市电输入]电压报警\"," +
                "\"epName\":\"电量仪\"," +
                "\"title\":\"电压\"," +
                "\"valueType\":\"BigDecimal\"," +
                "\"checks\":[{\"begin\":\"200\",\"end\":\"240\",\"algorithm\":\"RANGE\"}]}";
        System.out.println(CheckUtil.alarm(electricityMeter, json));
    }

}
